<!DOCTYPE html>
<html>
<head>
	<#include "/common/head.html"/>
</head>
<body>
	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">
				<div class="layui-card">
					<div class="layui-card-body">
						<form class="layui-form layui-row layui-col-space16" lay-filter="table-form">
							
						</form>

						<table class="layui-hide" id="table-main" lay-filter="table-main"></table>
						
						<script type="text/html" id="table-toolbar">
						<div class="layui-btn-group">
	<button type="button" class="layui-btn layui-btn-orange" lay-event="add">
    	<i class="layui-icon layui-icon-add-1"></i> 添加
  	</button>
	<button type="button" class="layui-btn layui-btn-danger" lay-event="del">
    	<i class="layui-icon layui-icon-delete"></i> 删除
  	</button>
</div>
</script>
						<script type="text/html" id="table-tool">
						<div class="layui-btn-group">
	<button type="button" class="layui-btn layui-btn-warm layui-btn-sm" lay-event="edit">
    	<i class="layui-icon layui-icon-edit"></i> 编辑
  	</button>
</div>
</script>
					</div>
				</div>
		</div>
	</div>
	
	<script>
		layui.use(function() {
			var table = layui.table;
			var form = layui.form;

			table.render({
				url : '/v1/role/page',
				where : {
				},
				cols : [ [ {
					type : 'checkbox',
					fixed : 'left'
				}, {
					field : 'id',
					title : 'ID',
					width : 180,
					fixed : 'left'
				}, {
					field : 'name',
					title : '名称',
					width : 150
				}, {
					field : 'code',
					title : '编码',
					width : 150
				}, {
					fixed : 'right',
					title : '操作',
					width : 125,
					minWidth : 125,
					toolbar : '#table-tool'
				} ] ]
			});
			
			table.on('toolbar(table-main)', function(obj) {
				if (obj.event === 'add') {
					xadmin.open('添加','/pp/system-role-edit')
				}else if (obj.event === 'del') {
					tableForDelete(table,obj,'/v1/role');
				}
			});
			
			table.on('tool(table-main)', function(obj){
				var data = obj.data;
				if(obj.event === 'edit'){
		        	xadmin.open('编辑','/pp/system-role-edit?id='+data.id)
				}
			});
		});
		
	</script>
	
</body>
</html>